<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<div class="aui-fullpage">
    <div class="aui-block aui-paginator-container">
        <lv-tabs [(lvActiveIndex)]="selectedViewType">
            <lv-tab lvTitle="{{'common_resource_label' | i18n}}" lvId='0'>
                <ng-template lv-tab-lazy>
                    <ng-container *ngTemplateOutlet="operationTpl"></ng-container>
                    <ng-container *ngIf="isResourceReplicaList">
                        <aui-resource-replica-list [resourceType]="resourceType" [childResourceType]="childResourceType"
                            #replicaResourceList>
                        </aui-resource-replica-list>
                    </ng-container>
                    <ng-container *ngIf="!isResourceReplicaList">
                        <aui-resource-list [resourceType]="resourceType" [childResourceType]="childResourceType"
                            #resourceList>
                        </aui-resource-list>
                    </ng-container>
                </ng-template>
            </lv-tab>
            <lv-tab lvTitle="{{'common_copies_label' | i18n}}" lvId='1'>
                <ng-template lv-tab-lazy>
                    <ng-container *ngTemplateOutlet="operationTpl"></ng-container>
                    <aui-copy-list [resourceType]="resourceType" [childResourceType]="childResourceType"
                        (onSelectionChange)="selectionChange($event)" #copyList>
                    </aui-copy-list>
                </ng-template>
            </lv-tab>
        </lv-tabs>
    </div>
</div>

<ng-template #operationTpl>
    <div class="aui-operation view-switch-operation">
        <lv-group [lvGutter]="groupCommon.middleRowGutter">
            <ng-container *ngIf="selectedViewType === '0'">
                <lv-search [lvFocus]="true" (lvSearch)="search($event)"
                    lvPlaceHolder="{{'common_search_type_label'|i18n:['common_resource_label'|i18n]}}">
                </lv-search>
            </ng-container>
            <lv-group>
                <button class="aui-button-icon" lv-button lvSize="auto" (click)="refresh()">
                    <i lv-icon="lv-icon-refresh" [lvColorState]="true"></i>
                </button>
            </lv-group>
        </lv-group>
        <ng-container *ngIf="selectedViewType === '1'">
            <button lv-button (click)="deleteCopyData()" [disabled]="deleteBtnDisable" pmpermission
                pmOperation='DeletingCopy'>
                {{ 'common_delete_label' | i18n }}
            </button>
        </ng-container>
    </div>
</ng-template>